package com.example.demo.service.impl;

import java.util.List;

import javax.transaction.Transactional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils;

import com.example.demo.dao.RoleDao;
import com.example.demo.dao.UserDao;
import com.example.demo.model.SysRoleModel;
import com.example.demo.model.SysUserModel;
import com.example.demo.service.UserService;

@Repository()
@Transactional
public class UserServiceImpl implements UserService {

	
	private static final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);
	
	@Autowired
	UserDao userDao;
	@Autowired
	RoleDao roleDao;
	
	
	@Override
	public Page<SysUserModel> queryUserPage(int pageNum,int pageSize){
		return userDao.queryUserPage(pageNum, pageSize);
	}
	
	
	
	
	@Override
	public void saveUser(SysUserModel user){
		userDao.save(user);
		logger.info("userDao.save保存用户方法结束.....");
	}




	@Override
	public int existLoginName(String loginName) {
		List<SysUserModel> userList = userDao.queryLoginName(loginName);
		if(CollectionUtils.isEmpty(userList)){
			return 0;
		}
		return 1;
	}
	
}
